package com.naiterui.ehp.bs.doctor.vo.medicine;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.naiterui.ehp.bp.utils.lang.ConfigUtil;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(value = "MedicineCycleUnitVO", description = "用药周期单位")
public class MedicineCycleUnitVO implements Serializable {

    /**
     * 字段或域定义：<code>serialVersionUID</code>
     */
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "周期日期单位:天、日、月等等")
    private String cycleDateUnit;

    @ApiModelProperty(value = "基数：代表多少天,如:单位是周的话，这个值就是7")
    private Integer baseNumber;

    public String getCycleDateUnit() {
        return this.cycleDateUnit;
    }

    public void setCycleDateUnit(String cycleDateUnit) {
        this.cycleDateUnit = cycleDateUnit;
    }

    public Integer getBaseNumber() {
        return this.baseNumber;
    }

    public void setBaseNumber(Integer baseNumber) {
        this.baseNumber = baseNumber;
    }

    public static List<MedicineCycleUnitVO> toVOList() {
        List<MedicineCycleUnitVO> list = new ArrayList<>();
        String cycleUnitList = ConfigUtil.getString("init.medicine.cycleUnitList");
        String[] strArray = cycleUnitList.split(",");
        for (String aStrArray : strArray) {
            MedicineCycleUnitVO vo = new MedicineCycleUnitVO();
            String[] str = aStrArray.split("-");
            vo.setCycleDateUnit(str[0]);
            vo.setBaseNumber(Integer.parseInt(str[1]));
            list.add(vo);
        }

        return list;
    }
}
